Charles Builds Stuff


How to make a website the strange way

Once upon a time, there was a guy who built stuff. He got into engineering school, and continued making cool things. But then, disaster struck: He had failed to document the cool things, so all his friends were getting the cool jobs that he wanted. Something had to be done.

And so, this website was born. GitHub pages was chosen as a host on the recommendation of a friend. Included in GitHub Pages is Jekyll, which allows for generation of blogs from markdown documents. It is a quick, easy, painless method for generating static pages and putting them on a website.

But where's the fun in that?

Indeed, opportunities to do things the entertaining way are the roots of almost all of my projects (Surely I can build a cheap chronograph!). "How hard can it be?" is the mother of re-invention.

What I needed was a piece of software that could sandwhich together pieces of content between headers and footers, and populate an index with their titles and preambles. Jekyll is capable of far more than just this, but I do not need far more than this. I chose to roll my own. So, I turned towards the many languages available. Python was the clear choice, with Java a close second.

So, needless to say, I went with a favorite of sysadmins and codegolfers everywhere: Windows PowerShell.

Why, you might ask? Simply, why not? It's a good scripting language with weak typing. Nowhere in a PowerShell manual will you see "explicit is better than implicit", so the scripts are short. Also, ever since my job doing load testing at Halogen, I've loved this language. It's fun to write, it's easy to work with, and it gets things done. It's pretty much Perl-lite (Which would also have been a good language to use here...) with a healthy helping of C# and Bash. There are pipes, but they're object oriented, but they're weakly typed.

If nothing else, it's an entertaining language, it isn't Python, and watching some of my programmer buddies squirm when I bring it up makes me all warm and fuzzy inside.

This is firmly in the prototype stage. I would not recommend that anyone else use my software for critical things. On the flipside, however, the code is short enough to be audited in a matter of minutes, and it does seem to work so far.

One of my goals in making this website was to create a website that was harkened back to the good-old-days, before bloated javascript frameworks, tracking scripts, or even javascript frameworks in general. At the time of writing, the entire site is devoid of anything dynamic.


The generator was based on a very basic understanding of what I wanted. I have no objections to writing HTML by hand, so processing Markdown or similar - RTF was (briefly) considered - would not be necessary. The code evolved into a mishmash of iterators, pipes, and selectors, based around the simple hope that I could write posts in HTML and stash a header atop them (to see what I mean, view /posts/website.html. Note the leading lines prior to the first p-tag.) This was easily accomplished by tagging a section of the header with a special comment that is replaced with almost all the contents of the hand-written post.

The next challenge was metadata, which remains an ongoing effort. First, a post title was added. Then, a post image was added. Subtitles, date of writing, and some other feature remain to be added, but may only arrive when the entire thing is re-written.

The preview of the post is generated by stripping all img tags and taking the first three lines that start with tags. The three paragraphs that come from this tend to be fairly good (if a touch clickbaity) preambles to each article, though this does require a degree of care when crafting these leading lines.